#include <google/protobuf/stubs/callback.h>
#include "fastrpc/rpc.hpp"
#include "hello.pb.h"
using namespace fastrpc::log;
using namespace fastrpc::io;
using namespace fastrpc::net;
using namespace fastrpc::async;
using namespace fastrpc;
using namespace fastrpc::rpc;

class myrpcservice : public rpc_serivce {
    void hello(google::protobuf::RpcController* controller,
               const ::Request*                 request,
               ::Response*                      response,
               google::protobuf::Closure*       done) {
        console.info("get requset is:{}", request->str());
        response->set_str("hello from rpcserver");
        if (done) {
            done->Run();
        }
        return;
    }
};

int main() {
    SET_LOG_LEVEL(fastrpc::log::LogLevel::Debug);
    RpcServer           server{10000};
    FastRpcClosure::ptr cb
        = std::make_shared<FastRpcClosure>([]() { std::cout << "this is rpc callback!!!\n"; });
    server.set_callback(cb.get());
    std::shared_ptr<myrpcservice> service = std::make_shared<myrpcservice>();
    server.register_service(service);
    server.run();
    return 0;
}
